﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using LuaInterface;
using LuaFramework;
using UnityEngine.UI;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace LuaFramework {
    public class LuaUtil {
        //设置坐标
        public static void SetPosition(GameObject o, float x, float y, float z) {
            if (o.transform)
            {
                o.transform.localPosition = new Vector3(x, y, z);
            }
            else
            {
                o.GetComponent<RectTransform>().localPosition = new Vector3(x, y, z);
            }
        }

        //设置缩放
        public static void SetScale(GameObject o, float x, float y, float z)
        {
            if (o.transform)
            {
                o.transform.localScale = new Vector3(x, y, z);
            }
            else
            {
                o.GetComponent<RectTransform>().localScale = new Vector3(x, y, z);
            }
        }

        //设置尺寸
        public static void SetSize(GameObject o, float x, float y)
        {
            o.GetComponent<RectTransform>().sizeDelta = new Vector2(x, y);
        }


        //设置尺寸
        public static string GetSize(GameObject o)
        {
            var pos = o.GetComponent<RectTransform>().sizeDelta;
            return pos.x + "," + pos.y;
        }
    }
}